package com.spy.material.dto;

import lombok.Data;
import javax.validation.Valid;
import javax.validation.constraints.*;
import java.math.BigDecimal;
import java.util.List;

/**
 * 新增采购单DTO
 */
@Data
public class PurchaseOrderCreateDTO {
    
    /**
     * 采购单标题
     */
    @NotBlank(message = "采购单标题不能为空")
    @Size(max = 100, message = "采购单标题长度不能超过100个字符")
    private String title;
    
    /**
     * 采购日期
     */
    @NotBlank(message = "采购日期不能为空")
    @Pattern(regexp = "\\d{4}-\\d{2}-\\d{2}", message = "采购日期格式必须为YYYY-MM-DD")
    private String purchaseDate;
    
    /**
     * 采购总数
     */
    @NotNull(message = "采购总数不能为空")
    @Min(value = 1, message = "采购总数必须大于0")
    private Integer totalPurchaseQuantity;
    
    /**
     * 采购总金额
     */
    @NotNull(message = "采购总金额不能为空")
    @DecimalMin(value = "0.0", inclusive = false, message = "采购总金额必须大于0")
    private BigDecimal purchaseTotalPrice;
    
    /**
     * 采购人
     */
    @NotBlank(message = "采购人不能为空")
    @Size(max = 50, message = "采购人姓名长度不能超过50个字符")
    private String purchaser;
    
    /**
     * 配送点
     */
    @NotBlank(message = "配送点不能为空")
    @Size(max = 100, message = "配送点名称长度不能超过100个字符")
    private String fullName;
    
    /**
     * 供应商
     */
    @NotBlank(message = "供应商不能为空")
    @Size(max = 100, message = "供应商名称长度不能超过100个字符")
    private String supplier;
    
    /**
     * 验收人
     */
    @NotBlank(message = "验收人不能为空")
    @Size(max = 50, message = "验收人姓名长度不能超过50个字符")
    private String acceptor;
    
    /**
     * 验收总数
     */
    @NotNull(message = "验收总数不能为空")
    @Min(value = 0, message = "验收总数不能为负数")
    private Integer actualReceivedTotal;
    
    /**
     * 实收总金额
     */
    @NotNull(message = "实收总金额不能为空")
    @DecimalMin(value = "0.0", message = "实收总金额不能为负数")
    private BigDecimal actualReceivedTotalPrice;
    
    /**
     * 验收日期
     */
    @NotBlank(message = "验收日期不能为空")
    @Pattern(regexp = "\\d{4}-\\d{2}-\\d{2}", message = "验收日期格式必须为YYYY-MM-DD")
    private String acceptanceDate;
    
    /**
     * 采购明细列表
     */
    @Valid
    @NotEmpty(message = "采购明细不能为空")
    private List<PurchaseOrderDetailCreateDTO> details;
}